package top.soulblack.purchasesale.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import top.soulblack.purchasesale.model.GoodsBrand;

import java.util.List;

/**
 * create by 小川
 */

@Mapper
public interface GoodsBrandMapper {

    int deleteById(Integer id);

    int insert(GoodsBrand record);

    int insertSelective(GoodsBrand record);

    GoodsBrand selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(GoodsBrand record);

    int updateByPrimaryKey(GoodsBrand record);

    @Select("select * from goods_brand")
    List<GoodsBrand> selectAll();

    @Insert("insert into goods_brand (name, url, `describe`, sort) values (#{name}, #{url}, #{describe}, #{sort})")
    void addBrand(GoodsBrand goodsBrand);

    @Select("select * from goods_brand where name = #{brandName} order by sort")
    List<GoodsBrand> selectForName(@Param("brandName") String brandName);

    @Select("select count(*) from goods_brand where name = #{name}")
    int existBrand(String name);

    @Select("select brand from goods where brand = #{id}")
    List<Integer> selectBrand(@Param("id") Integer id);
}
